/*
 * ProcessScheduler.h
 *
 *  Created on: Mar 11, 2013
 *      Author: Aaron Kaufman
 */

#ifndef PROCESSSCHEDULER_H_
#define PROCESSSCHEDULER_H_
#include "data.h"

typedef enum {BLOCKED, RUNNING, RUNNABLE} current_state;
typedef enum scheduler_type{
	ROUND_ROBIN,
	LOTTERY,
	PRIORITY
	//Priority schedulers allocate time as a multiple of the given priority.
	//Do priority scheduling by explicitly assigning priorities.
} ScheduleType;

typedef struct process{
	current_state state;
	tdata_t data;
	int priority;
} Process;


typedef struct scheduler{
	ScheduleType type;
	int current_process;
	Process* processes[300];
	int size;
} Scheduler;

typedef struct ProcessList{
	int size;
	Process processes[30];
} ProcessList;

typedef struct process_scheduler {
	ProcessList process_list;
	Scheduler scheduler;
} ProcessScheduler;

ProcessList initializeProcessList(ProcessScheduler* process_scheduler);
void initializeProcessScheduler(ProcessScheduler* process_scheduler);//Call this before anything else.
void addProcessToList(Process process, ProcessScheduler* process_scheduler);
void buildNewSchedule(ScheduleType type, ProcessScheduler* process_scheduler);
Process* getNextProcess(ProcessScheduler* process_scheduler);
Process* getNewProcess(Process* current, ProcessScheduler* this);

#endif /* PROCESSSCHEDULER_H_ */
